home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / unixcpio.gz / unixnet.cpio / kiss.c < prev    next >
C/C++ Source or Header  |  1994-07-11  |  1KB  |  70 lines

  1. #include "global.h"
  2. #include "mbuf.h"
  3. #include "iface.h"
  4. #include "kiss.h"
  5. #include "trace.h"
  6.  
  7. /* Send raw data packet on KISS TNC */
  8. kiss_raw(interface,data)
  9. struct interface *interface;
  10. struct mbuf *data;
  11. {
  12.     register struct mbuf *bp;
  13.  
  14.     dump(interface,IF_TRACE_OUT,TRACE_AX25,data);
  15.  
  16.     /* Put type field for KISS TNC on front */
  17.     if((bp = pushdown(data,1)) == NULLBUF){
  18.         free_p(data);
  19.         return;
  20.     }
  21.     bp->data[0] = KISS_DATA;
  22.  
  23.     slip_raw(interface,bp);
  24. }
  25.  
  26. /* Process incoming KISS TNC frame */
  27. void
  28. kiss_recv(interface,bp)
  29. struct interface *interface;
  30. struct mbuf *bp;
  31. {
  32.     char kisstype;
  33.  
  34.     kisstype = pullchar(&bp);
  35.     switch(kisstype & 0xf){
  36.     case KISS_DATA:
  37.         dump(interface,IF_TRACE_IN,TRACE_AX25,bp);
  38.         ax_recv(interface,bp);
  39.         break;
  40.     }
  41. }
  42. /* Perform device control on KISS TNC by sending control messages */
  43. kiss_ioctl(interface,argc,argv)
  44. struct interface *interface;
  45. int argc;
  46. char *argv[];
  47. {
  48.     struct mbuf *hbp;
  49.     int i;
  50.     char *cp;
  51.  
  52.     if(argc < 1){
  53.         printf("Data field missing\r\n");
  54.         return 1;
  55.     }
  56.     /* Allocate space for arg bytes */
  57.     if((hbp = alloc_mbuf((int16)argc)) == NULLBUF){
  58.         free_p(hbp);
  59.         return 0;
  60.     }
  61.     hbp->cnt = argc;
  62.     hbp->next = NULLBUF;
  63.     for(i=0,cp = hbp->data;i < argc;)
  64.         *cp++ = atoi(argv[i++]);
  65.  
  66.     slip_raw(interface,hbp);    /* Even more "raw" than kiss_raw */
  67.     return 0;
  68. }
  69.  
  70.